<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="../common.jsp"%>
<%@ page import="org.springside.core.Constants"%>
<%@ page import="cn.firstsoft.firstframe.admin.Environment"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="org.jdom.*,org.jdom.input.*,org.jdom.output.*" %>
<%@ page import="cn.firstsoft.firstframe.admin.time.*"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>管理控制台 - 服务信息</title>
<%@ include file="/common/meta2.jsp"%>
<link href="../style.css" type="text/css" rel=stylesheet>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="#FFFFFF">
<script language="javascript">
  function modifyCron(id,cron){
    cronText  = document.getElementById(cron);
    idText  = document.getElementById(id);
    document.timer.attribute.value = "cronExpression";
    document.timer.bean.value = "trigger";
    document.timer.beanID.value = idText.value;
    document.timer.modifyType.value = "modify";
    document.timer.attributeValue.value = cronText.value;
    if(document.timer.attributeValue.value == "") {
       alert("定时器触发时间不能为空！");
       cronText.focus;
       return false;
    }
    document.timer.submit();
  }

</script>

<%

String xml = System.getProperty("oa_application.config") + File.separator  + "cn" + File.separator  + "firstsoft" + File.separator  + "firstframe" + File.separator  + "plugins" + File.separator  + "quartz" + File.separator  + "applicationContext-quartz.xml";
QuartzXmlBean qxb = new QuartzXmlBean(xml);
List<String> triggersID = qxb.getTriggersID();
List<CronTriggerBean> triggers = qxb.getTriggers();
List<MethodInvokingJobDetailFactoryBean> jobs = qxb.getJobDetail();
%>
<FORM name="timer" method="post" action="timer_update.jsp">
<INPUT type="hidden" name="modifyType" value="modify">
<INPUT type="hidden" name="bean" value="trigger">
<INPUT type="hidden" name="beanID" value="">
<INPUT type="hidden" name="attribute" value="cronExpression">
<INPUT type="hidden" name="attributeValue" value="">
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		定时器信息

		</TD>
	</TR>

    <TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    定时器配置文路径:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%=xml%>
	    </TD>
        <TD class=tabDetailViewDF vAlign=top width="10%">
	    <a href="file_download.jsp?filePath=<%=xml%>&fileName=applicationContext-quartz.xml" tagert="_blank">下载</a>&nbsp;&nbsp;
	    </TD>
	</TR>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		quartzScheduler属性设置

		</TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    triggers:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
<%
for(int i=0;i<triggersID.size();i++){
  out.println(triggersID.get(i)+"&nbsp;&nbsp;");
}
%>
	    </TD>
        <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;&nbsp;
	    </TD>
	</TR>
	<TR>
	    <TD class=tabDetailViewDL vAlign=top width="15%">
	    configLocation:&nbsp;
	    </TD>
	    <TD class=tabDetailViewDF vAlign=top width="75%">
        <%out.println(qxb.getSchedulerFactoryBean().getConfigLocation());%>
	    </TD>
        <TD class=tabDetailViewDF vAlign=top width="10%">
	    &nbsp;&nbsp;
	    </TD>
	</TR>
	
	
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		Trigger属性设置

		</TD>
	</TR>
	
	<TR>
		<TD colSpan=20>
		<table cellSpacing=0 cellPadding=0 width="100%" border=0>
		  <tr>
		    <td class=listViewPaginationTdS1>
		     序号
		    </td>
		    <td class=listViewPaginationTdS1>
		     ID
		    </td>
		    <td class=listViewPaginationTdS1>
		     JobDetail
		    </td>
		    <td class=listViewPaginationTdS1>
		     cronExpression
		    </td>
		    <td class=listViewPaginationTdS1>
		     &nbsp;
		    </td>
		  </tr>
<%
for(int i =0; i<triggers.size();) {
  CronTriggerBean ctb = triggers.get(i);
%>
		  <tr>
		    <td class=tabDetailViewDL>
		     <%=++i%>
		    </td>
		    <td class=tabDetailViewDF>
		     <%=ctb.getId()%>
		    </td>
		    <td class=tabDetailViewDF>
		     <%=ctb.getJobDetail()%>
		    </td>
		    <td class=tabDetailViewDF>
		     <input id="triggerCrom<%=i%>"  type="text" name="triggerCrom<%=i%>" value="<%=ctb.getCronExpression()%>">
		     <input id="triggerID<%=i%>"  type="hidden" name="triggerID<%=i%>" value="<%=ctb.getId()%>">
		    </td>
		    <td class=tabDetailViewDF>
		     <input type="button" name="changeCron<%=i%>" value="修改" title="修改定时器触发时间" onClick="modifyCron('triggerID<%=i%>','triggerCrom<%=i%>');" >&nbsp;
		     <input type="button" name="deleteCron<%=i%>" value="删除" title="删除定时器" onClick="DeleteCron();" disabled>&nbsp;
		    </td>
		  </tr>
<%
}
%>	
		</table>
		</TD>
	</TR>
	<TR>
		<TD class=listViewPaginationTdS1 colSpan=20>
		JobDetail属性设置

		</TD>
	</TR>
	
	<TR>
		<TD colSpan=20>
		<table cellSpacing=0 cellPadding=0 width="100%" border=0>
		  <tr>
		    <td class=listViewPaginationTdS1>
		     序号
		    </td>
		    <td class=listViewPaginationTdS1>
		     ID
		    </td>
		    <td class=listViewPaginationTdS1>
		     targetObject
		    </td>
		    <td class=listViewPaginationTdS1>
		     targetMethod
		    </td>
		    <td class=listViewPaginationTdS1>
		     &nbsp;
		    </td>
		  </tr>
<%
for(int i =0; i<jobs.size();) {
  MethodInvokingJobDetailFactoryBean job = jobs.get(i);
%>
		  <tr>
		    <td class=tabDetailViewDL>
		     <%=++i%>
		    </td>
		    <td class=tabDetailViewDF>
		     <%=job.getId()%>
		    </td>
		    <td class=tabDetailViewDF>
		     <%=job.getTargetObject()%>
		    </td>
		    <td class=tabDetailViewDF>
		     <%=job.getTargetMethod()%>
		    </td>
		    <td class=tabDetailViewDF>
		     &nbsp;
		    </td>
		  </tr>
<%
}
%>	
		</table>
		</TD>
	</TR>
	</TBODY>
</TABLE>
<%




//XMLOutputter outputter = new XMLOutputter(); 
//outputter.output(doc, System.out); 

%>
</body>
</html>